{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "NDB_No               int64\n",
      "Shrt_Desc           object\n",
      "Water_(g)          float64\n",
      "Energ_Kcal           int64\n",
      "Protein_(g)        float64\n",
      "Lipid_Tot_(g)      float64\n",
      "Ash_(g)            float64\n",
      "Carbohydrt_(g)     float64\n",
      "Fiber_TD_(g)       float64\n",
      "Sugar_Tot_(g)      float64\n",
      "Calcium_(mg)       float64\n",
      "Iron_(mg)          float64\n",
      "Magnesium_(mg)     float64\n",
      "Phosphorus_(mg)    float64\n",
      "Potassium_(mg)     float64\n",
      "Sodium_(mg)        float64\n",
      "Zinc_(mg)          float64\n",
      "Copper_(mg)        float64\n",
      "Manganese_(mg)     float64\n",
      "Selenium_(mcg)     float64\n",
      "Vit_C_(mg)         float64\n",
      "Thiamin_(mg)       float64\n",
      "Riboflavin_(mg)    float64\n",
      "Niacin_(mg)        float64\n",
      "Vit_B6_(mg)        float64\n",
      "Vit_B12_(mcg)      float64\n",
      "Vit_A_IU           float64\n",
      "Vit_A_RAE          float64\n",
      "Vit_E_(mg)         float64\n",
      "Vit_D_mcg          float64\n",
      "Vit_D_IU           float64\n",
      "Vit_K_(mcg)        float64\n",
      "FA_Sat_(g)         float64\n",
      "FA_Mono_(g)        float64\n",
      "FA_Poly_(g)        float64\n",
      "Cholestrl_(mg)     float64\n",
      "dtype: object\n",
      "Help on function read_csv in module pandas.io.parsers:\n",
      "\n",
      "read_csv(filepath_or_buffer, sep=',', delimiter=None, header='infer', names=None, index_col=None, usecols=None, squeeze=False, prefix=None, mangle_dupe_cols=True, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skipinitialspace=False, skiprows=None, skipfooter=None, nrows=None, na_values=None, keep_default_na=True, na_filter=True, verbose=False, skip_blank_lines=True, parse_dates=False, infer_datetime_format=False, keep_date_col=False, date_parser=None, dayfirst=False, iterator=False, chunksize=None, compression='infer', thousands=None, decimal=b'.', lineterminator=None, quotechar='\"', quoting=0, escapechar=None, comment=None, encoding=None, dialect=None, tupleize_cols=False, error_bad_lines=True, warn_bad_lines=True, skip_footer=0, doublequote=True, delim_whitespace=False, as_recarray=False, compact_ints=False, use_unsigned=False, low_memory=True, buffer_lines=None, memory_map=False, float_precision=None)\n",
      "    Read CSV (comma-separated) file into DataFrame\n",
      "    \n",
      "    Also supports optionally iterating or breaking of the file\n",
      "    into chunks.\n",
      "    \n",
      "    Additional help can be found in the `online docs for IO Tools\n",
      "    <http://pandas.pydata.org/pandas-docs/stable/io.html>`_.\n",
      "    \n",
      "    Parameters\n",
      "    ----------\n",
      "    filepath_or_buffer : str, pathlib.Path, py._path.local.LocalPath or any object with a read() method (such as a file handle or StringIO)\n",
      "        The string could be a URL. Valid URL schemes include http, ftp, s3, and\n",
      "        file. For file URLs, a host is expected. For instance, a local file could\n",
      "        be file ://localhost/path/to/table.csv\n",
      "    sep : str, default ','\n",
      "        Delimiter to use. If sep is None, will try to automatically determine\n",
      "        this. Separators longer than 1 character and different from '\\s+' will be\n",
      "        interpreted as regular expressions, will force use of the python parsing\n",
      "        engine and will ignore quotes in the data. Regex example: '\\r\\t'\n",
      "    delimiter : str, default ``None``\n",
      "        Alternative argument name for sep.\n",
      "    delim_whitespace : boolean, default False\n",
      "        Specifies whether or not whitespace (e.g. ``' '`` or ``'    '``) will be\n",
      "        used as the sep. Equivalent to setting ``sep='\\+s'``. If this option\n",
      "        is set to True, nothing should be passed in for the ``delimiter``\n",
      "        parameter.\n",
      "    \n",
      "        .. versionadded:: 0.18.1 support for the Python parser.\n",
      "    \n",
      "    header : int or list of ints, default 'infer'\n",
      "        Row number(s) to use as the column names, and the start of the data.\n",
      "        Default behavior is as if set to 0 if no ``names`` passed, otherwise\n",
      "        ``None``. Explicitly pass ``header=0`` to be able to replace existing\n",
      "        names. The header can be a list of integers that specify row locations for\n",
      "        a multi-index on the columns e.g. [0,1,3]. Intervening rows that are not\n",
      "        specified will be skipped (e.g. 2 in this example is skipped). Note that\n",
      "        this parameter ignores commented lines and empty lines if\n",
      "        ``skip_blank_lines=True``, so header=0 denotes the first line of data\n",
      "        rather than the first line of the file.\n",
      "    names : array-like, default None\n",
      "        List of column names to use. If file contains no header row, then you\n",
      "        should explicitly pass header=None\n",
      "    index_col : int or sequence or False, default None\n",
      "        Column to use as the row labels of the DataFrame. If a sequence is given, a\n",
      "        MultiIndex is used. If you have a malformed file with delimiters at the end\n",
      "        of each line, you might consider index_col=False to force pandas to _not_\n",
      "        use the first column as the index (row names)\n",
      "    usecols : array-like, default None\n",
      "        Return a subset of the columns. All elements in this array must either\n",
      "        be positional (i.e. integer indices into the document columns) or strings\n",
      "        that correspond to column names provided either by the user in `names` or\n",
      "        inferred from the document header row(s). For example, a valid `usecols`\n",
      "        parameter would be [0, 1, 2] or ['foo', 'bar', 'baz']. Using this parameter\n",
      "        results in much faster parsing time and lower memory usage.\n",
      "    squeeze : boolean, default False\n",
      "        If the parsed data only contains one column then return a Series\n",
      "    prefix : str, default None\n",
      "        Prefix to add to column numbers when no header, e.g. 'X' for X0, X1, ...\n",
      "    mangle_dupe_cols : boolean, default True\n",
      "        Duplicate columns will be specified as 'X.0'...'X.N', rather than 'X'...'X'\n",
      "    dtype : Type name or dict of column -> type, default None\n",
      "        Data type for data or columns. E.g. {'a': np.float64, 'b': np.int32}\n",
      "        (Unsupported with engine='python'). Use `str` or `object` to preserve and\n",
      "        not interpret dtype.\n",
      "    engine : {'c', 'python'}, optional\n",
      "        Parser engine to use. The C engine is faster while the python engine is\n",
      "        currently more feature-complete.\n",
      "    converters : dict, default None\n",
      "        Dict of functions for converting values in certain columns. Keys can either\n",
      "        be integers or column labels\n",
      "    true_values : list, default None\n",
      "        Values to consider as True\n",
      "    false_values : list, default None\n",
      "        Values to consider as False\n",
      "    skipinitialspace : boolean, default False\n",
      "        Skip spaces after delimiter.\n",
      "    skiprows : list-like or integer, default None\n",
      "        Line numbers to skip (0-indexed) or number of lines to skip (int)\n",
      "        at the start of the file\n",
      "    skipfooter : int, default 0\n",
      "        Number of lines at bottom of file to skip (Unsupported with engine='c')\n",
      "    nrows : int, default None\n",
      "        Number of rows of file to read. Useful for reading pieces of large files\n",
      "    na_values : str or list-like or dict, default None\n",
      "        Additional strings to recognize as NA/NaN. If dict passed, specific\n",
      "        per-column NA values.  By default the following values are interpreted as\n",
      "        NaN: `''`, `'#N/A'`, `'#N/A N/A'`, `'#NA'`, `'-1.#IND'`, `'-1.#QNAN'`, `'-NaN'`, `'-nan'`, `'1.#IND'`, `'1.#QNAN'`, `'N/A'`, `'NA'`, `'NULL'`, `'NaN'`, `'nan'`.\n",
      "    keep_default_na : bool, default True\n",
      "        If na_values are specified and keep_default_na is False the default NaN\n",
      "        values are overridden, otherwise they're appended to.\n",
      "    na_filter : boolean, default True\n",
      "        Detect missing value markers (empty strings and the value of na_values). In\n",
      "        data without any NAs, passing na_filter=False can improve the performance\n",
      "        of reading a large file\n",
      "    verbose : boolean, default False\n",
      "        Indicate number of NA values placed in non-numeric columns\n",
      "    skip_blank_lines : boolean, default True\n",
      "        If True, skip over blank lines rather than interpreting as NaN values\n",
      "    parse_dates : boolean or list of ints or names or list of lists or dict, default False\n",
      "    \n",
      "        * boolean. If True -> try parsing the index.\n",
      "        * list of ints or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3\n",
      "          each as a separate date column.\n",
      "        * list of lists. e.g.  If [[1, 3]] -> combine columns 1 and 3 and parse as\n",
      "            a single date column.\n",
      "        * dict, e.g. {'foo' : [1, 3]} -> parse columns 1, 3 as date and call result\n",
      "          'foo'\n",
      "    \n",
      "        Note: A fast-path exists for iso8601-formatted dates.\n",
      "    infer_datetime_format : boolean, default False\n",
      "        If True and parse_dates is enabled, pandas will attempt to infer the format\n",
      "        of the datetime strings in the columns, and if it can be inferred, switch\n",
      "        to a faster method of parsing them. In some cases this can increase the\n",
      "        parsing speed by ~5-10x.\n",
      "    keep_date_col : boolean, default False\n",
      "        If True and parse_dates specifies combining multiple columns then\n",
      "        keep the original columns.\n",
      "    date_parser : function, default None\n",
      "        Function to use for converting a sequence of string columns to an array of\n",
      "        datetime instances. The default uses ``dateutil.parser.parser`` to do the\n",
      "        conversion. Pandas will try to call date_parser in three different ways,\n",
      "        advancing to the next if an exception occurs: 1) Pass one or more arrays\n",
      "        (as defined by parse_dates) as arguments; 2) concatenate (row-wise) the\n",
      "        string values from the columns defined by parse_dates into a single array\n",
      "        and pass that; and 3) call date_parser once for each row using one or more\n",
      "        strings (corresponding to the columns defined by parse_dates) as arguments.\n",
      "    dayfirst : boolean, default False\n",
      "        DD/MM format dates, international and European format\n",
      "    iterator : boolean, default False\n",
      "        Return TextFileReader object for iteration or getting chunks with\n",
      "        ``get_chunk()``.\n",
      "    chunksize : int, default None\n",
      "        Return TextFileReader object for iteration. `See IO Tools docs for more\n",
      "        information\n",
      "        <http://pandas.pydata.org/pandas-docs/stable/io.html#io-chunking>`_ on\n",
      "        ``iterator`` and ``chunksize``.\n",
      "    compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, default 'infer'\n",
      "        For on-the-fly decompression of on-disk data. If 'infer', then use gzip,\n",
      "        bz2, zip or xz if filepath_or_buffer is a string ending in '.gz', '.bz2',\n",
      "        '.zip', or 'xz', respectively, and no decompression otherwise. If using\n",
      "        'zip', the ZIP file must contain only one data file to be read in.\n",
      "        Set to None for no decompression.\n",
      "    \n",
      "        .. versionadded:: 0.18.1 support for 'zip' and 'xz' compression.\n",
      "    \n",
      "    thousands : str, default None\n",
      "        Thousands separator\n",
      "    decimal : str, default '.'\n",
      "        Character to recognize as decimal point (e.g. use ',' for European data).\n",
      "    lineterminator : str (length 1), default None\n",
      "        Character to break file into lines. Only valid with C parser.\n",
      "    quotechar : str (length 1), optional\n",
      "        The character used to denote the start and end of a quoted item. Quoted\n",
      "        items can include the delimiter and it will be ignored.\n",
      "    quoting : int or csv.QUOTE_* instance, default None\n",
      "        Control field quoting behavior per ``csv.QUOTE_*`` constants. Use one of\n",
      "        QUOTE_MINIMAL (0), QUOTE_ALL (1), QUOTE_NONNUMERIC (2) or QUOTE_NONE (3).\n",
      "        Default (None) results in QUOTE_MINIMAL behavior.\n",
      "    escapechar : str (length 1), default None\n",
      "        One-character string used to escape delimiter when quoting is QUOTE_NONE.\n",
      "    comment : str, default None\n",
      "        Indicates remainder of line should not be parsed. If found at the beginning\n",
      "        of a line, the line will be ignored altogether. This parameter must be a\n",
      "        single character. Like empty lines (as long as ``skip_blank_lines=True``),\n",
      "        fully commented lines are ignored by the parameter `header` but not by\n",
      "        `skiprows`. For example, if comment='#', parsing '#empty\\na,b,c\\n1,2,3'\n",
      "        with `header=0` will result in 'a,b,c' being\n",
      "        treated as the header.\n",
      "    encoding : str, default None\n",
      "        Encoding to use for UTF when reading/writing (ex. 'utf-8'). `List of Python\n",
      "        standard encodings\n",
      "        <https://docs.python.org/3/library/codecs.html#standard-encodings>`_\n",
      "    dialect : str or csv.Dialect instance, default None\n",
      "        If None defaults to Excel dialect. Ignored if sep longer than 1 char\n",
      "        See csv.Dialect documentation for more details\n",
      "    tupleize_cols : boolean, default False\n",
      "        Leave a list of tuples on columns as is (default is to convert to\n",
      "        a Multi Index on the columns)\n",
      "    error_bad_lines : boolean, default True\n",
      "        Lines with too many fields (e.g. a csv line with too many commas) will by\n",
      "        default cause an exception to be raised, and no DataFrame will be returned.\n",
      "        If False, then these \"bad lines\" will dropped from the DataFrame that is\n",
      "        returned. (Only valid with C parser)\n",
      "    warn_bad_lines : boolean, default True\n",
      "        If error_bad_lines is False, and warn_bad_lines is True, a warning for each\n",
      "        \"bad line\" will be output. (Only valid with C parser).\n",
      "    \n",
      "    Returns\n",
      "    -------\n",
      "    result : DataFrame or TextParser\n",
      "\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "import pandas\n",
    "food_info = pandas.read_csv(\"food_info.csv\")\n",
    "print(type(food_info))\n",
    "print (food_info.dtypes)\n",
    "print (help(pandas.read_csv))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(8618, 36)\n"
     ]
    }
   ],
   "source": [
    "#food_info.head(3)\n",
    "#first_rows = food_info.head()\n",
    "#first_rows\n",
    "#food_info.tail(4)\n",
    "#print(food_info.tail(3))\n",
    "#print (food_info.columns)\n",
    "print (food_info.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NDB_No                         1001\n",
      "Shrt_Desc          BUTTER WITH SALT\n",
      "Water_(g)                     15.87\n",
      "Energ_Kcal                      717\n",
      "Protein_(g)                    0.85\n",
      "Lipid_Tot_(g)                 81.11\n",
      "Ash_(g)                        2.11\n",
      "Carbohydrt_(g)                 0.06\n",
      "Fiber_TD_(g)                      0\n",
      "Sugar_Tot_(g)                  0.06\n",
      "Calcium_(mg)                     24\n",
      "Iron_(mg)                      0.02\n",
      "Magnesium_(mg)                    2\n",
      "Phosphorus_(mg)                  24\n",
      "Potassium_(mg)                   24\n",
      "Sodium_(mg)                     643\n",
      "Zinc_(mg)                      0.09\n",
      "Copper_(mg)                       0\n",
      "Manganese_(mg)                    0\n",
      "Selenium_(mcg)                    1\n",
      "Vit_C_(mg)                        0\n",
      "Thiamin_(mg)                  0.005\n",
      "Riboflavin_(mg)               0.034\n",
      "Niacin_(mg)                   0.042\n",
      "Vit_B6_(mg)                   0.003\n",
      "Vit_B12_(mcg)                  0.17\n",
      "Vit_A_IU                       2499\n",
      "Vit_A_RAE                       684\n",
      "Vit_E_(mg)                     2.32\n",
      "Vit_D_mcg                       1.5\n",
      "Vit_D_IU                         60\n",
      "Vit_K_(mcg)                       7\n",
      "FA_Sat_(g)                   51.368\n",
      "FA_Mono_(g)                  21.021\n",
      "FA_Poly_(g)                   3.043\n",
      "Cholestrl_(mg)                  215\n",
      "Name: 0, dtype: object\n"
     ]
    }
   ],
   "source": [
    "#pandas uses zero-indexing\n",
    "#Series object representing the row at index 0.\n",
    "print (food_info.loc[0])\n",
    "\n",
    "# Series object representing the seventh row.\n",
    "#food_info.loc[6]\n",
    "\n",
    "# Will throw an error: \"KeyError: 'the label [8620] is not in the [index]'\"\n",
    "#food_info.loc[8620]\n",
    "#The object dtype is equivalent to a string in Python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#object - For string values\n",
    "#int - For integer values\n",
    "#float - For float values\n",
    "#datetime - For time values\n",
    "#bool - For Boolean values\n",
    "#print(food_info.dtypes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>NDB_No</th>\n",
       "      <th>Shrt_Desc</th>\n",
       "      <th>Water_(g)</th>\n",
       "      <th>Energ_Kcal</th>\n",
       "      <th>Protein_(g)</th>\n",
       "      <th>Lipid_Tot_(g)</th>\n",
       "      <th>Ash_(g)</th>\n",
       "      <th>Carbohydrt_(g)</th>\n",
       "      <th>Fiber_TD_(g)</th>\n",
       "      <th>Sugar_Tot_(g)</th>\n",
       "      <th>...</th>\n",
       "      <th>Vit_A_IU</th>\n",
       "      <th>Vit_A_RAE</th>\n",
       "      <th>Vit_E_(mg)</th>\n",
       "      <th>Vit_D_mcg</th>\n",
       "      <th>Vit_D_IU</th>\n",
       "      <th>Vit_K_(mcg)</th>\n",
       "      <th>FA_Sat_(g)</th>\n",
       "      <th>FA_Mono_(g)</th>\n",
       "      <th>FA_Poly_(g)</th>\n",
       "      <th>Cholestrl_(mg)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1003</td>\n",
       "      <td>BUTTER OIL ANHYDROUS</td>\n",
       "      <td>0.24</td>\n",
       "      <td>876</td>\n",
       "      <td>0.28</td>\n",
       "      <td>99.48</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>...</td>\n",
       "      <td>3069.0</td>\n",
       "      <td>840.0</td>\n",
       "      <td>2.80</td>\n",
       "      <td>1.8</td>\n",
       "      <td>73.0</td>\n",
       "      <td>8.6</td>\n",
       "      <td>61.924</td>\n",
       "      <td>28.732</td>\n",
       "      <td>3.694</td>\n",
       "      <td>256.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1006</td>\n",
       "      <td>CHEESE BRIE</td>\n",
       "      <td>48.42</td>\n",
       "      <td>334</td>\n",
       "      <td>20.75</td>\n",
       "      <td>27.68</td>\n",
       "      <td>2.70</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.45</td>\n",
       "      <td>...</td>\n",
       "      <td>592.0</td>\n",
       "      <td>174.0</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.5</td>\n",
       "      <td>20.0</td>\n",
       "      <td>2.3</td>\n",
       "      <td>17.410</td>\n",
       "      <td>8.013</td>\n",
       "      <td>0.826</td>\n",
       "      <td>100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1011</td>\n",
       "      <td>CHEESE COLBY</td>\n",
       "      <td>38.20</td>\n",
       "      <td>394</td>\n",
       "      <td>23.76</td>\n",
       "      <td>32.11</td>\n",
       "      <td>3.36</td>\n",
       "      <td>2.57</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.52</td>\n",
       "      <td>...</td>\n",
       "      <td>994.0</td>\n",
       "      <td>264.0</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.6</td>\n",
       "      <td>24.0</td>\n",
       "      <td>2.7</td>\n",
       "      <td>20.218</td>\n",
       "      <td>9.280</td>\n",
       "      <td>0.953</td>\n",
       "      <td>95.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 36 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    NDB_No             Shrt_Desc  Water_(g)  Energ_Kcal  Protein_(g)  \\\n",
       "2     1003  BUTTER OIL ANHYDROUS       0.24         876         0.28   \n",
       "5     1006           CHEESE BRIE      48.42         334        20.75   \n",
       "10    1011          CHEESE COLBY      38.20         394        23.76   \n",
       "\n",
       "    Lipid_Tot_(g)  Ash_(g)  Carbohydrt_(g)  Fiber_TD_(g)  Sugar_Tot_(g)  \\\n",
       "2           99.48     0.00            0.00           0.0           0.00   \n",
       "5           27.68     2.70            0.45           0.0           0.45   \n",
       "10          32.11     3.36            2.57           0.0           0.52   \n",
       "\n",
       "         ...        Vit_A_IU  Vit_A_RAE  Vit_E_(mg)  Vit_D_mcg  Vit_D_IU  \\\n",
       "2        ...          3069.0      840.0        2.80        1.8      73.0   \n",
       "5        ...           592.0      174.0        0.24        0.5      20.0   \n",
       "10       ...           994.0      264.0        0.28        0.6      24.0   \n",
       "\n",
       "    Vit_K_(mcg)  FA_Sat_(g)  FA_Mono_(g)  FA_Poly_(g)  Cholestrl_(mg)  \n",
       "2           8.6      61.924       28.732        3.694           256.0  \n",
       "5           2.3      17.410        8.013        0.826           100.0  \n",
       "10          2.7      20.218        9.280        0.953            95.0  \n",
       "\n",
       "[3 rows x 36 columns]"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Returns a DataFrame containing the rows at indexes 3, 4, 5, and 6.\n",
    "food_info.loc[3:6]\n",
    "\n",
    "# Returns a DataFrame containing the rows at indexes 2, 5, and 10. Either of the following approaches will work.\n",
    "# Method 1\n",
    "#two_five_ten = [2,5,10] \n",
    "#food_info.loc[two_five_ten]\n",
    "\n",
    "# Method 2\n",
    "#food_info.loc[[2,5,10]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0        1001\n",
      "1        1002\n",
      "2        1003\n",
      "3        1004\n",
      "4        1005\n",
      "5        1006\n",
      "6        1007\n",
      "7        1008\n",
      "8        1009\n",
      "9        1010\n",
      "10       1011\n",
      "11       1012\n",
      "12       1013\n",
      "13       1014\n",
      "14       1015\n",
      "15       1016\n",
      "16       1017\n",
      "17       1018\n",
      "18       1019\n",
      "19       1020\n",
      "20       1021\n",
      "21       1022\n",
      "22       1023\n",
      "23       1024\n",
      "24       1025\n",
      "25       1026\n",
      "26       1027\n",
      "27       1028\n",
      "28       1029\n",
      "29       1030\n",
      "        ...  \n",
      "8588    43544\n",
      "8589    43546\n",
      "8590    43550\n",
      "8591    43566\n",
      "8592    43570\n",
      "8593    43572\n",
      "8594    43585\n",
      "8595    43589\n",
      "8596    43595\n",
      "8597    43597\n",
      "8598    43598\n",
      "8599    44005\n",
      "8600    44018\n",
      "8601    44048\n",
      "8602    44055\n",
      "8603    44061\n",
      "8604    44074\n",
      "8605    44110\n",
      "8606    44158\n",
      "8607    44203\n",
      "8608    44258\n",
      "8609    44259\n",
      "8610    44260\n",
      "8611    48052\n",
      "8612    80200\n",
      "8613    83110\n",
      "8614    90240\n",
      "8615    90480\n",
      "8616    90560\n",
      "8617    93600\n",
      "Name: NDB_No, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# Series object representing the \"NDB_No\" column.\n",
    "ndb_col = food_info[\"NDB_No\"]\n",
    "print (ndb_col)\n",
    "# Alternatively, you can access a column by passing in a string variable.\n",
    "#col_name = \"NDB_No\"\n",
    "#ndb_col = food_info[col_name]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "      Zinc_(mg)  Copper_(mg)\n",
      "0          0.09        0.000\n",
      "1          0.05        0.016\n",
      "2          0.01        0.001\n",
      "3          2.66        0.040\n",
      "4          2.60        0.024\n",
      "5          2.38        0.019\n",
      "6          2.38        0.021\n",
      "7          2.94        0.024\n",
      "8          3.43        0.056\n",
      "9          2.79        0.042\n",
      "10         3.07        0.042\n",
      "11         0.40        0.029\n",
      "12         0.33        0.040\n",
      "13         0.47        0.030\n",
      "14         0.51        0.033\n",
      "15         0.38        0.028\n",
      "16         0.51        0.019\n",
      "17         3.75        0.036\n",
      "18         2.88        0.032\n",
      "19         3.50        0.025\n",
      "20         1.14        0.080\n",
      "21         3.90        0.036\n",
      "22         3.90        0.032\n",
      "23         2.10        0.021\n",
      "24         3.00        0.032\n",
      "25         2.92        0.011\n",
      "26         2.46        0.022\n",
      "27         2.76        0.025\n",
      "28         3.61        0.034\n",
      "29         2.81        0.031\n",
      "...         ...          ...\n",
      "8588       3.30        0.377\n",
      "8589       0.05        0.040\n",
      "8590       0.05        0.030\n",
      "8591       1.15        0.116\n",
      "8592       5.03        0.200\n",
      "8593       3.83        0.545\n",
      "8594       0.08        0.035\n",
      "8595       3.90        0.027\n",
      "8596       4.10        0.100\n",
      "8597       3.13        0.027\n",
      "8598       0.13        0.000\n",
      "8599       0.02        0.000\n",
      "8600       0.09        0.037\n",
      "8601       0.21        0.026\n",
      "8602       2.77        0.571\n",
      "8603       0.41        0.838\n",
      "8604       0.05        0.028\n",
      "8605       0.03        0.023\n",
      "8606       0.10        0.112\n",
      "8607       0.02        0.020\n",
      "8608       1.49        0.854\n",
      "8609       0.19        0.040\n",
      "8610       0.10        0.038\n",
      "8611       0.85        0.182\n",
      "8612       1.00        0.250\n",
      "8613       1.10        0.100\n",
      "8614       1.55        0.033\n",
      "8615       0.19        0.020\n",
      "8616       1.00        0.400\n",
      "8617       1.00        0.250\n",
      "\n",
      "[8618 rows x 2 columns]\n"
     ]
    }
   ],
   "source": [
    "columns = [\"Zinc_(mg)\", \"Copper_(mg)\"]\n",
    "zinc_copper = food_info[columns]\n",
    "print (zinc_copper)\n",
    "#print zinc_copper\n",
    "# Skipping the assignment.\n",
    "#zinc_copper = food_info[[\"Zinc_(mg)\", \"Copper_(mg)\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['NDB_No', 'Shrt_Desc', 'Water_(g)', 'Energ_Kcal', 'Protein_(g)', 'Lipid_Tot_(g)', 'Ash_(g)', 'Carbohydrt_(g)', 'Fiber_TD_(g)', 'Sugar_Tot_(g)', 'Calcium_(mg)', 'Iron_(mg)', 'Magnesium_(mg)', 'Phosphorus_(mg)', 'Potassium_(mg)', 'Sodium_(mg)', 'Zinc_(mg)', 'Copper_(mg)', 'Manganese_(mg)', 'Selenium_(mcg)', 'Vit_C_(mg)', 'Thiamin_(mg)', 'Riboflavin_(mg)', 'Niacin_(mg)', 'Vit_B6_(mg)', 'Vit_B12_(mcg)', 'Vit_A_IU', 'Vit_A_RAE', 'Vit_E_(mg)', 'Vit_D_mcg', 'Vit_D_IU', 'Vit_K_(mcg)', 'FA_Sat_(g)', 'FA_Mono_(g)', 'FA_Poly_(g)', 'Cholestrl_(mg)']\n",
      "   Water_(g)  Protein_(g)  Lipid_Tot_(g)  Ash_(g)  Carbohydrt_(g)  \\\n",
      "0      15.87         0.85          81.11     2.11            0.06   \n",
      "1      15.87         0.85          81.11     2.11            0.06   \n",
      "2       0.24         0.28          99.48     0.00            0.00   \n",
      "\n",
      "   Fiber_TD_(g)  Sugar_Tot_(g)  FA_Sat_(g)  FA_Mono_(g)  FA_Poly_(g)  \n",
      "0           0.0           0.06      51.368       21.021        3.043  \n",
      "1           0.0           0.06      50.489       23.426        3.012  \n",
      "2           0.0           0.00      61.924       28.732        3.694  \n"
     ]
    }
   ],
   "source": [
    "#print(food_info.columns)\n",
    "#print(food_info.head(2))\n",
    "col_names = food_info.columns.tolist()\n",
    "print (col_names)\n",
    "gram_columns = []\n",
    "\n",
    "for c in col_names:\n",
    "    if c.endswith(\"(g)\"):\n",
    "        gram_columns.append(c)\n",
    "gram_df = food_info[gram_columns]\n",
    "print(gram_df.head(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
